Validate component properties #264 - March 1#452
Validate component properties #264 - March 1#452rmarren1 wants to merge 46 commits intoplotly:masterfrom
Conversation
|
Thanks, I'll have a good look on friday review party. |
| mimetype='application/json' | ||
| ) | ||
|
|
||
| self.callback_map[callback_id]['func'] = func |
There was a problem hiding this comment.
Why do that in two difference part ? Couldn't your additions in dispatch be in add_context ?
There was a problem hiding this comment.
We would have to pass namespace, component_id, component_property, to this since that info is available in dispatch. I originally thought this might clash with the other arguments (e.g. if you had a property called namespace) although I now think this would be fine, but it might make it difficult if we want to support passing props with keyword arguments in the future.
For the |
|
Updates:
Bumped all release candidates. |
|
Tested the RCs with dash-docs, and a few Dash apps I have built. |
|
|
Testing the demo with the rc version I got a figure validation error and the message:
Is it |
Shouldn't |
I think the graph now put a random id if there's none. |
|
Wanted to note that the issue I raised in the other thread still exists. Numerical types in checklist values and dropdown values (and probably other components too) still raise errors with the latest release. |
|
Updated top level comment, the correct way to turn off validation is by setting |
|
This was a really great effort and was in line to be a PR of the Year 🏆 . In the end, with the addition of alternative language backends for Dash (DashR), we decided to double down on the Dash Dev Tools UI and invest & maintain the validation code in the front-end. |
Note: This PR is a continuation of #340. That PR had ~80 comments (most were outdated and no longer relevant), and 96 commits. This PR is the same code, just more readable.
PR for #264
Current Prerelease
Validation is on by default. To turn it off, you can set
app.config.suppress_validation_exceptions = TrueTest Cases to run for demo
Example Error Messages
PropTypes to Cerberus reference
array{'type': 'list'}bool{'type': 'boolean'}func{}object{'type': 'dict'}dictobject. We cannot be more general (e.g.collections.abc.Mapping) since the coreComponentis an instance of that.string{'type': 'string'}symbol{}node{'anyof': [{'type': 'component'}, {'type': 'boolean'}, {'type': 'number'}, {'type': 'string'}, {'type': 'list', 'schema': {'anyof': [{'type': 'component'}, {'type': 'boolean'}, {'type': 'number'}, {'type': 'string'}]}}]}instanceOf(Object){}oneOf(['val1', 2]){'allowed': [None, 'val1', 2]}'characters stripped off each end. This is becausemetadata.jsongeneration serializes the literal values as json, so for examplePropTypes.oneOf(['News', 'Photos'])serializes to["'News'", "'Photos'"]. reactjs/react-docgen#57oneOfType( [ PropTypes.string, PropTypes.bool ] ){'anyof': [{'type': 'string', 'type': 'boolean'}]}PropTypethat cannot be validated individually (e.g.PropType.func), no validation will occur and the schema will effectively be{}arrayOf( PropTypes.number ){'type': 'list', 'schema': {'type': 'number'}}objectOf( PropTypes.number ){'type': 'dict', 'valueschema': {'type': 'number'}}shape( { k1: PropTypes.string, k2: PropTypes.number } ){'type': 'dict', 'allow_unknown': False, 'schema': {'k1': {'type': 'string}, 'k2': {'type': 'number'}}}any{'type': ('boolean', 'number', 'string', 'dict', 'list')}